package com.usian.controller;

import com.usian.pojo.User;
import com.usian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RequestMapping("user")
@RestController
@RefreshScope
public class UserController {

    @Autowired
    private UserService userService;



    @RequestMapping("findById/{id}")

    public User findById(@PathVariable Integer id){
        return userService.findById(id);
    }

    @GetMapping("/findByIdd")
    public User findByIdd(Integer id) {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        User user = userService.findById(id);
        return user;
    }

    @PostMapping("/findByUser")
    public User findByUser(@RequestBody User user) {
        userService.findById(user.getId());
        return user;
    }

}
